﻿
Partial Class GetPrice
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Session("IDCity") Is Nothing Or Request.QueryString("IDKS") Is Nothing Then
            Response.Redirect("~/index.aspx")
        End If
        If Not IsPostBack Then
            'DetailKhachSan.aspx?IDKS={0}
            Dim khachSan As KhachSan = Nothing
            If Request.QueryString("IDKS") IsNot Nothing Then
                Dim idKS As New Guid(Request.QueryString("IDKS"))
                khachSan = KhachSanServer.GetKhachSanByIDKhachSan(idKS)
                ' Dim strCity As String = KhachSanServer.GetCityNameByIDCity(khachSan.CITY_ID)

                'Dim arrivalDate As Date = Session("ArrivalDate")
                'Dim departureDate As Date = Session("DepartureDate")
                'Dim nDays As Long = DateDiff("d", arrivalDate, departureDate)
                'Dim _Date As Date = DateAdd(DateInterval.Day, +1, Now.Date)
                'Dim strDayWeek As String = String.Format("{0} {1}", Util.GetStrThuTrongTuan(arrivalDate.DayOfWeek), Format("MM/dd/yyyy", arrivalDate))
                'Dim lstItem As New ListItem(nDays, arrivalDate)

                divNameHotel.InnerHtml = khachSan.NAME
                lnkQuayLai.Text = "Khách Sạn tại " + Session("NameCity")
                Dim strURLQuayLai As String = String.Format("~/SearchKhachSan.aspx?ArrivalDate={0}&DepartureDate={1}&CityID={2}&Guests={3}&Rooms={4}", Session("ArrivalDate"), Session("DepartureDate"), Session("IDCity"), Session("Guests"), Session("Rooms"))
                lnkQuayLai.PostBackUrl = strURLQuayLai
            End If
            'Dim strPathAndQuery As String = HttpContext.Current.Request.Url.PathAndQuery
            'Dim strUrl As String = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "")
            'strUrl = strUrl & khachSan.LINK
        End If
    End Sub

    Protected Sub lnkGuiGiaTot_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkGuiGiaTot.Click
        Try

            Dim idKS As New Guid(Request.QueryString("IDKS"))
            Dim khachSan As KhachSan = KhachSanServer.GetKhachSanByIDKhachSan(idKS)
            Dim idLP As Guid = Nothing
            Dim idKM As Guid = Nothing

            Dim khuyenMai As New KhuyenMaiTheoHotel
            Dim loaiPhongKS As New KhachSan
            Dim strContent As String = String.Format("Email: {0} <br/>Phone: {1} <br/> Muốn nhận giá phòng của {2} <br/>", txtEmail.Text, txtMobile.Text, khachSan.NAME)

            If Request.QueryString("IDLP") IsNot Nothing Then
                idLP = New Guid(Request.QueryString("IDLP"))
                loaiPhongKS = KhachSanServer.GetLoaiHotelByIdLoaiPhong(idKS, idLP)
                strContent = String.Format(" {0} Loại phòng: {1} <br/>", strContent, loaiPhongKS.NAMELOAIPHONG)
                strContent = String.Format(" {0} Đường dẫn: {1} <br/>", strContent, khachSan.LINK)
            End If
            If Request.QueryString("IDKM") IsNot Nothing Then
                idKM = New Guid(Request.QueryString("IDKM"))
                khuyenMai = KhuyenMaiTheoHotelServer.GetKhuyenMaiByIDKhuyenMai(idKS, idKM)
                strContent = String.Format(" {0} Khuyến mãi: {1} <br/>", strContent, khuyenMai.NAME_KM)
                strContent = String.Format(" {0} Đường dẫn: {1} <br/>", strContent, khachSan.LINK)
            End If

            DatPhongServer.InsertFeedBack(txtEmail.Text, txtMobile.Text, khachSan.NAME, strContent)

            Dim strURLQuayLai As String = String.Format("~/DetailKhachSan.aspx?IDKS={0}", Request.QueryString("IDKS"))
            Response.Redirect(strURLQuayLai)
        
        Catch ex As Exception
            ''Throw ex
        End Try
    End Sub
End Class
